package com.mazaiting.mybatisplus.sensitive.handler;

import com.mazaiting.mybatisplus.sensitive.ISensitive;
import com.mazaiting.mybatisplus.sensitive.constants.RegexConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 手机号脱敏
 * @author danghailiang
 */
public class MobileSensitiveHandler implements ISensitive {
    /**
     * 日志服务
     */
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 获取脱敏手机号
     * @param value 待脱敏的参数
     * @return 返回被脱敏的字符串
     */
    @Override
    public String paramSensitive(Object value) {
        String metaData = value.toString();
        logger.info("metaData:{}",metaData);
        String regexData = metaData.replaceAll(RegexConstant.REGEX_PHONE, RegexConstant.REPLACE_FOUR_STAR);
        logger.info("regexData:{}",regexData);
        return regexData;
    }
}
